🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / feature / map / src / commonMain / kotlin / org / meshtastic / feature / map / MapBounds.kt
Displaying Raw • Download
feature/map/src/commonMain/kotlin/org/meshtastic/feature/map/MapBounds.kt renovate/fastlane-2.x-lockfile (056eed64) Text, 3.50 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.feature.map
Tff7b72import T7ee787org.meshtastic.core.model.Node
T8b949e/** A point on the map, in degrees. Deliberately not either renderer's type — see [MapBounds]. */
Tff7b72data Tff7b72class T56d364MapPointTb4b4b4(Tff7b72val Te6edf3latitudeTb4b4b4: Tffa657DoubleTb4b4b4, Tff7b72val Te6edf3longitudeTb4b4b4: Tffa657DoubleTb4b4b4)
T8b949e/**
* A latitude/longitude box, in degrees.
*
* Neither renderer's box: MapLibre has `spatialk`'s `BoundingBox` and the Google map has `LatLngBounds`, and each
* converts this at its own edge. Keeping the maths here is the point — it is the same maths, and it lived only in the
* MapLibre module, which the Google flavour cannot depend on, so the Google map hand-rolled `LatLngBounds.builder()` in
* three places instead.
*/
Tff7b72data Tff7b72class T56d364MapBoundsTb4b4b4(Tff7b72val Te6edf3southTb4b4b4: Tffa657DoubleTb4b4b4, Tff7b72val Te6edf3westTb4b4b4: Tffa657DoubleTb4b4b4, Tff7b72val Te6edf3northTb4b4b4: Tffa657DoubleTb4b4b4, Tff7b72val Te6edf3eastTb4b4b4: Tffa657DoubleTb4b4b4) Tb4b4b4{
Tff7b72companion Tff7b72object Tb4b4b4{
T8b949e/**
* A box covering [points], or null when there are none.
*
* Null rather than a box at (0, 0): treating "no data yet" as a real location is how the OSMdroid map used to
* open in the Atlantic.
*
* A single point, or several stacked on one spot, yields a zero-area box the camera cannot fit to — a
* stationary node's whole position track is exactly that — so a degenerate box is padded to something framable.
*
* Longitudes are min/maxed linearly, so a mesh straddling the antimeridian fits the long way round. Deliberate,
* matching the KML converter's polygon stance: wrapped bounds would have to flow through two renderers'
* camera-fit APIs to pay off, and no mesh this app has met sits on the date line.
*/
Tff7b72fun Td2a8ffaroundTb4b4b4(Te6edf3pointsTb4b4b4: Te6edf3ListTff7b72<Te6edf3MapPointTff7b72>Tb4b4b4)Tb4b4b4: Te6edf3MapBounds? Tb4b4b4{
Tff7b72if Tb4b4b4(Te6edf3pointsTb4b4b4.Te6edf3isEmptyTb4b4b4(Tb4b4b4)Tb4b4b4) Tff7b72return Tff7b72null
Tff7b72var Te6edf3south Tff7b72= Te6edf3pointsTb4b4b4.Te6edf3firstTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3latitude
Tff7b72var Te6edf3north Tff7b72= Te6edf3south
Tff7b72var Te6edf3west Tff7b72= Te6edf3pointsTb4b4b4.Te6edf3firstTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3longitude
Tff7b72var Te6edf3east Tff7b72= Te6edf3west
Te6edf3pointsTb4b4b4.Te6edf3forEach Tb4b4b4{ Te6edf3point Tff7b72-Tff7b72>
Te6edf3south Tff7b72= Te6edf3minOfTb4b4b4(Te6edf3southTb4b4b4, Te6edf3pointTb4b4b4.Te6edf3latitudeTb4b4b4)
Te6edf3north Tff7b72= Te6edf3maxOfTb4b4b4(Te6edf3northTb4b4b4, Te6edf3pointTb4b4b4.Te6edf3latitudeTb4b4b4)
Te6edf3west Tff7b72= Te6edf3minOfTb4b4b4(Te6edf3westTb4b4b4, Te6edf3pointTb4b4b4.Te6edf3longitudeTb4b4b4)
Te6edf3east Tff7b72= Te6edf3maxOfTb4b4b4(Te6edf3eastTb4b4b4, Te6edf3pointTb4b4b4.Te6edf3longitudeTb4b4b4)
Tb4b4b4}
Tff7b72if Tb4b4b4(Te6edf3south Tff7b72=Tff7b72= Te6edf3north Tff7b72&Tff7b72& Te6edf3west Tff7b72=Tff7b72= Te6edf3eastTb4b4b4) Tb4b4b4{
Te6edf3south Tff7b72-Tff7b72= Te6edf3SINGLE_POINT_PAD_DEG
Te6edf3north Tff7b72+Tff7b72= Te6edf3SINGLE_POINT_PAD_DEG
Te6edf3west Tff7b72-Tff7b72= Te6edf3SINGLE_POINT_PAD_DEG
Te6edf3east Tff7b72+Tff7b72= Te6edf3SINGLE_POINT_PAD_DEG
Tb4b4b4}
Tff7b72return Te6edf3MapBoundsTb4b4b4(Te6edf3south Tff7b72= Te6edf3southTb4b4b4, Te6edf3west Tff7b72= Te6edf3westTb4b4b4, Te6edf3north Tff7b72= Te6edf3northTb4b4b4, Te6edf3east Tff7b72= Te6edf3eastTb4b4b4)
Tb4b4b4}
T8b949e/** A box covering every node that has a fix, or null when none does. */
Tff7b72fun Td2a8ffaroundNodesTb4b4b4(Te6edf3nodesTb4b4b4: Te6edf3ListTff7b72<Te6edf3NodeTff7b72>Tb4b4b4)Tb4b4b4: Te6edf3MapBounds? Tff7b72=
Te6edf3aroundTb4b4b4(Te6edf3nodesTb4b4b4.Te6edf3filter Tb4b4b4{ Tffa657itTb4b4b4.Te6edf3validPosition Tff7b72!Tff7b72= Tff7b72null Tb4b4b4}Tb4b4b4.Te6edf3map Tb4b4b4{ Te6edf3MapPointTb4b4b4(Tffa657itTb4b4b4.Te6edf3latitudeTb4b4b4, Tffa657itTb4b4b4.Te6edf3longitudeTb4b4b4) Tb4b4b4}Tb4b4b4)
Tff7b72private Tff7b72const Tff7b72val Te6edf3SINGLE_POINT_PAD_DEG Tff7b72= T79c0ff0.01
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.2 - Generated in 0.17s